package edu.uic.kott.activities;

import edu.uic.keyoutcomestrackertool.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class StudentProfileView extends Activity {

	TextView nameTextView;
	TextView studentIdTextView;
	TextView schoolNameTextView	;
	TextView studentEmailTextView;
	TextView majorTextView;

	public static final String StudentProfile = "studentProfile";
	public static final String Name = "name";
	public static final String StudentID = "studentID";
	public static final String SchoolName = "schoolName";
	public static final String StudentEmail = "studentEmail";
	public static final String Major = "major";

	static SharedPreferences studentProfile;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.student_profile_view);

		nameTextView = (TextView) findViewById(R.id.profile_view_name);
		studentIdTextView = (TextView) findViewById(R.id.profile_view_studentid);
		schoolNameTextView = (TextView) findViewById(R.id.profile_view_schoolname);
		studentEmailTextView = (TextView) findViewById(R.id.profile_view_studentemail);
		majorTextView = (TextView) findViewById(R.id.profile_view_major);

		studentProfile = getSharedPreferences(StudentProfile, Context.MODE_PRIVATE);

		if (studentProfile.contains(Name)) {
			nameTextView.setText(studentProfile.getString(Name, ""));
		}


		if (studentProfile.contains(StudentID)) {
			studentIdTextView.setText(studentProfile.getString(StudentID, ""));
		}

		if (studentProfile.contains(SchoolName)) {
			schoolNameTextView.setText(studentProfile.getString(SchoolName, ""));
		}

		if (studentProfile.contains(StudentEmail)) {
			studentEmailTextView.setText(studentProfile.getString(StudentEmail, ""));
		}

		if (studentProfile.contains(Major)) {
			majorTextView.setText(studentProfile.getString(Major, ""));
		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_edit_profile, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		startActivity(new Intent(StudentProfileView.this, StudentProfileEdit.class));
		return super.onOptionsItemSelected(item);
	}

}
